home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / xlate09.arc / MANUAL.TXT < prev    next >
Text File  |  1987-02-19  |  40KB  |  1,650 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.               M6809 to M68000 Assembly Language Source Translator
  33.               ---------------------------------------------------
  34.  
  35.  
  36.                                  Users Manual
  37.                                  ------------
  38.                                VERSAdos Ver 1.2
  39.                                MS-DOS   Ver 1.2
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                                                        Author : Mike Catherwood
  48.  
  49.                                                                  Motorola Ltd.,
  50.                                                                  East Kilbride
  51.                                                        Ver 1.0 : June 1986
  52.                                                        Ver 1.1 : Jan  1987
  53.                                                        Ver 1.2 : Feb  1987
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.               M6809 to M68000 Assembly Language Source Translator
  69.               ---------------------------------------------------
  70.  
  71.  
  72.  
  73.  
  74.  
  75.                              CHAPTER  1
  76.  
  77.                             INTRODUCTION
  78.  
  79.  
  80. 1.1  INTRODUCTION
  81. =================
  82.  
  83.  
  84.           The M6809 to M68000 assembly language source translator is  a  Pascal
  85.  
  86. utility  which  is  available  in versions to run under VERSAdos and MS-DOS.  It
  87.  
  88. accepts as input a legal M6809 source program and produces as output an  M68000
  89.  
  90. source file and a file containing a list of translation errors.  In addition to
  91.  
  92. the errors, warnings are also appended to the output file, indicating  possible
  93.  
  94. problem  areas.   The  original M6809 source may also be optionally interleaved
  95.  
  96. with the output M68000 code.  Standard Motorola assembler  syntax  is  assumed,
  97.  
  98. however,  modification  for use with other assemblers may be possible (refer to
  99.  
  100. Chapter 5).
  101.  
  102.  
  103.           Subsequent  to  translation,  the  M68000  source  may  be  optimised
  104.  
  105. manually or subjected to an optimisation utility which will  identify  some  of
  106.  
  107. the  more  obvious  redundant code constructs.  Customisation to the new target
  108.  
  109. enviroment will ofcourse need to be performed manually.
  110.  
  111.  
  112.           The objectives of the translator were as follows :
  113.  
  114.  
  115.  
  116. a) To provide around a 90% translation capability.
  117.  
  118. b) To flag constructs which are not translatable and/or may be problematic.
  119.  
  120. c) To maximise efficiency through the use of complex addressing modes wherever
  121.  
  122.    possible.
  123.  
  124. d) To provide the user with some translation flexiblity to allow a degree
  125.  
  126.    of customisation, and to simplify the development of future versions.
  127.  
  128.  
  129.  
  130.                                       -2-
  131.  
  132.  
  133.  
  134.               M6809 to M68000 Assembly Language Source Translator
  135.               ---------------------------------------------------
  136.  
  137.  
  138. e) To allow the utility to be easily ported onto alternative hosts.
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. 1.2 OPERATION DESCRIPTION
  146. =========================
  147.  
  148.  
  149.           The M6809 registers are represented in the M68000 as data and address
  150.  
  151. registers  as  defined  in  Section  3.3  .   Some temporary registers are also
  152.  
  153. reserved for use by translated code.  The remainder may be freely used  by  any
  154.  
  155. other  resident  user  code.  Notice that the the M68000 stack pointers are not
  156.  
  157. used by the translated program except for  calls  to  small  subroutines  which
  158.  
  159. simulate  untranslatable  instructions and/or correct translation inaccuracies.
  160.  
  161. This code is refered to as the stub and must  be  linked  with  the  translated
  162.  
  163. code.   The  translator  will  automatically include external references to the
  164.  
  165. stub.
  166.  
  167.  
  168.           The  program  operates  with  two  ascii  files which are essentially
  169.  
  170. tables that act as databases for the translator.  They are user alterable  (see
  171.  
  172. Chapter 5).  The first (CODES) contains a list of grouped M6809 opcodes and the
  173.  
  174. corresponding M68000 fundamental translations (plus warnings  if  appropriate).
  175.  
  176. For  example,  COMA and COMB are grouped as "*COM", the * indicating the opcode
  177.  
  178. may be associated with  different  registers.   Instruction  ABX,  however,  is
  179.  
  180. represented  in  the CODES database as "ABX" as it is inherent.  The associated
  181.  
  182. translation string contains one or more lines of translated code and  warnings.
  183.  
  184. Details such as operation size, destination/source effective addresses and code
  185.  
  186. to compensate for translation inadequacies, are  appended  by  the  translator.
  187.  
  188. For example, the AND opcode is represented as follows (the  reader should refer
  189.  
  190. to Chapter 5 for a description of the tokens used  and  how  to  customise  the
  191.  
  192. databases) :
  193.  
  194.  
  195.  
  196.                                       -3-
  197.  
  198.  
  199.  
  200.               M6809 to M68000 Assembly Language Source Translator
  201.               ---------------------------------------------------
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.                  *AND
  210.                  AND. o,D\;* C-BIT CLEARED *
  211.  
  212.           The warning is enclosed within '*' delimiters.  This example shows an
  213.  
  214. incompatibility  between  the  6809  and  68000  status  register  carry  bits.
  215.  
  216. Warnings are issued when there is a minor incompatibility for which -
  217.  
  218.  
  219.  
  220.  
  221.         a) A problematic situation may arise,
  222. and/or  b) the amount of code required to correct it was not considered
  223.            justifiable for all occurances of the instruction.
  224.  
  225.  
  226.           Should  these  differences create a problem, the user may selectively
  227.  
  228. append corrective M68000 code,  or  may  opt  to  add  this  code  globally  by
  229.  
  230. modifying the corresponding database.
  231.  
  232.  
  233.           The second file (CODES2) contains a list of opcodes which -
  234.  
  235.  
  236.  
  237.  
  238. (1) Have no operand associated with them and translate without an operand
  239.     (e.g. RTI translates to RTE),
  240.  
  241. (2) Contains an operand which will not require modification
  242.     (e.g. RMB 256 translates to DS.B 256),
  243.  
  244. (3) Translate to an opcode with a predetermined operand
  245.     (e.g. RTS translates to BSR ..RTS).
  246.  
  247.  
  248.           The  translator  does  not  differentiate  between  instructions  and
  249.  
  250. assembler directives.   Consequently,  CODES2  comprises  mainly  of  directive
  251.  
  252. translations.
  253.  
  254.  
  255.           Translator directives may be added to the 6809 source file to control
  256.  
  257. the translation process, allowing the user to insert additional 68000 code into
  258.  
  259. the original 6809 source code prior to  translation  (refer  to  Section  2.2).
  260.  
  261.  
  262.                                       -4-
  263.  
  264.  
  265.  
  266.               M6809 to M68000 Assembly Language Source Translator
  267.               ---------------------------------------------------
  268.  
  269.  
  270.  
  271. Provided  the  translator  is  active and the input line is not a comment, each
  272.  
  273. source line is parsed and the label, opcode, operand  and  comment  fields  are
  274.  
  275. identified.  The operand is then examined to determine the addressing mode used
  276.  
  277. and is modified accordingly.  The databases are then scanned to attempt to find
  278.  
  279. an  opcode  match  after  which the corresponding root translation is obtained.
  280.  
  281. Any  necessary  additional  instructions  are  then  appended  and   size   and
  282.  
  283. source/destination  effective  addresses  are  inserted prior to the code being
  284.  
  285. sent to the output file.   The  output  file format may leave insufficient room
  286.  
  287. for an existing comment.  Should this situation arise, the translator will
  288.  
  289. insert an additional comment line and continue the comment in the comment field
  290.  
  291. of the new line.
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                       -5-
  329.  
  330.  
  331.  
  332.               M6809 to M68000 Assembly Language Source Translator
  333.               ---------------------------------------------------
  334.  
  335.  
  336.  
  337.  
  338.  
  339.                              CHAPTER  2
  340.  
  341.                         USING THE TRANSLATOR
  342.  
  343.  
  344. 2.1  COMMAND
  345. ============
  346.  
  347.  
  348.           The  translator is invoked by entering the VERSAdos or MS-DOS commands
  349.  
  350. of the following form:
  351.  
  352.  
  353.  
  354. a) VERSAdos -
  355.  
  356.          TRANS09 <file1>,<file2>;<options>
  357.  
  358. where:
  359.  
  360.          <file1>    is the name of the file containing the M6809 source
  361.                     program. The default extension is .SA .
  362.  
  363.          <file2>    is the name of the file that will contain the M68000
  364.                     source program produced by the translator. The default
  365.                     extension is .SA . If <file2> is omitted, then no output
  366.                     file will be generated.
  367.  
  368.                     NOTE : 1) If <file2> already exists it will be overwritten
  369.                     ----      with the new output from the translator.
  370.  
  371.          <options>  may be one of the following :
  372.  
  373.                     I : Interleave original source lines into translated
  374.                         output file as comments.
  375.  
  376.                    -I : Do not interleave original source into output file.
  377.                         Default is condition is -I.
  378.  
  379.              Z=<size> : where <size> is the number of Kbytes to be used in
  380.                         the data area of the translator. Default is Z=24.
  381.  
  382.                        NOTE : If an "Error: heap overflow" message appears
  383.                        ----   during execution, the Z parameter should be
  384.                               increased.
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                                       -6-
  395.  
  396.  
  397.  
  398.               M6809 to M68000 Assembly Language Source Translator
  399.               ---------------------------------------------------
  400.  
  401.  
  402. b) MS-DOS -
  403.  
  404.          TRANS09 <file1> <file2> <options>
  405.  
  406. where:
  407.  
  408.          <file1>    is the name of the file containing the M6809 source
  409.                     program. Any file extension may be used.
  410.  
  411.          <file2>    is the name of the file that will contain the M68000
  412.                     source program produced by the translator. The extension
  413.                     will be as specified. If <file2> is omitted, the program
  414.                     will be aborted.
  415.  
  416.                     NOTE : 1) If <file2> already exists it will be overwritten
  417.                     ----      with the new output from the translator.
  418.  
  419.          <options>  may be one of the following :
  420.  
  421.                     I : Interleave original source lines into translated
  422.                         output file as comments.
  423.  
  424.                    -I : Do not interleave original source into output file.
  425.                         Default is condition is -I.
  426.  
  427.  
  428. 2.2 GENERAL USE
  429. ===============
  430.  
  431.  
  432.           The following points should be noted before  attempting  to  use  the
  433.  
  434. translator :
  435.  
  436.  
  437.  
  438. a) The user should be totally familiar with both the target and host hardware
  439.    and software (operating system/executive) enviroments.
  440.  
  441. b) The user should be familiar with the limitations and restrictions that
  442.    apply to this translator, and their implications in his system.
  443.  
  444.  
  445.           When the translator is invoked, there will be a short delay while  it
  446.  
  447. reads the databases into an array structure.  It will then proceed to translate
  448.  
  449. each input source line, periodically  updating  the  screen  with  the  current
  450.  
  451. status.   This  includes  a  count  of  the  number  of  input and output lines
  452.  
  453. (excluding  comments)  which  provides  an  approximate  idea  of   translation
  454.  
  455. efficiency.   A  running total of the number of errors encountered and warnings
  456.  
  457. produced are also displayed.  During operation, the translator will  produce  a
  458.  
  459.  
  460.                                       -7-
  461.  
  462.  
  463.  
  464.               M6809 to M68000 Assembly Language Source Translator
  465.               ---------------------------------------------------
  466.  
  467.  
  468.  
  469. file  containing  a  list  of any errors called ERRORS.SA (VERSAdos)/ERRORS.TXT
  470.  
  471. (MS-DOS). Should the error count not be zero after translation, this file  will
  472.  
  473. contain  the  problem  source  lines  and  their position in both the input and
  474.  
  475. output files (to assist subsequent editing).  The output file will also contain
  476.  
  477. an error message at the line where the error was encountered :
  478.  
  479.  
  480.  
  481.  
  482.         ** ERROR   <message>
  483.          *         <source line>
  484.  
  485.  
  486.           The source line comment directive is indented by one column to  force
  487.  
  488. an  error should this file be inadvertantly assembled.  Refer to appendix A for
  489.  
  490. a list of error conditions.
  491.  
  492.  
  493.           Warnings  are  inserted into the translator output file only and take
  494.  
  495. the following form.
  496.  
  497.  
  498.  
  499.        ** WARNING **         <message>
  500.  
  501.  
  502.  
  503. 2.3  TRANSLATOR CONTROL
  504. =======================
  505.  
  506.  
  507.           Operation of the translator may be controlled through the use of  the
  508.  
  509. following directives when encountered in the input source file.
  510.  
  511.  
  512.  
  513.        **PASS                Turn translator off
  514.  
  515.        **PASSOFF             Turn translator on
  516.  
  517.  
  518.           The contents of the file sandwiched between these directives will  be
  519.  
  520. treated  as comment lines.  The first character of the directives must occur in
  521.  
  522. column 1.  This feature allows the user to enter a block of M68000 source  code
  523.  
  524.  
  525.  
  526.                                       -8-
  527.  
  528.  
  529.  
  530.               M6809 to M68000 Assembly Language Source Translator
  531.               ---------------------------------------------------
  532.  
  533.  
  534. into  the  input  source  file  which will be passed through to the output file
  535.  
  536. (less the control directives) by the translator.
  537.  
  538.  
  539.  
  540.  
  541. 2.4  POST-TRANSLATION PROCEDURE
  542. ===============================
  543.  
  544.  
  545.           After  translation,  the output file should be checked for errors and
  546.  
  547. warning.  Errors must be corrected  or  compensated  for.   Warning  should  be
  548.  
  549. examined  for  their  significance  and  the code modified where necessary.  It
  550.  
  551. is likely that the vast majority of warnings will not  require  any  code
  552.  
  553. modification.   The  user  may  consider  it  useful to make a note of any such
  554.  
  555. changes or additions.
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.          NOTE : 1)  Special attention must be paid to code which relies
  563.          ----   on parameter passing through the U or S stacks. To reduce
  564.                 the M68000 code overhead, the translator will not attempt
  565.                 to compensate for any differences which may arise. See
  566.                 Chapter 4 for details.
  567.  
  568.                 2)  To minimise software overhead, the translator assumes
  569.                 that indirect addressing mode operands lie between $0 to
  570.                 $7FFF. The user must append additional code as necessary to
  571.                 correct for this anomoly (see Chapter 3). Failure to do so
  572.                 will cause the automatic sign extension performed by the
  573.                 M68000 to form an invalid effective address for the instuction.
  574.  
  575.  
  576. The  module may now be assembled.  The object code produced must then be linked
  577.  
  578. with the stub file (STUB09.RO {VERSAdos}/STUB09.BIN  {MS-DOS}).   If  necessary,
  579.  
  580. the stub source can be modified and reassembled before linking.
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                                       -9-
  593.  
  594.  
  595.  
  596.               M6809 to M68000 Assembly Language Source Translator
  597.               ---------------------------------------------------
  598.  
  599.  
  600.  
  601.  
  602.  
  603.                              CHAPTER  3
  604.  
  605.                           TRANSLATION RULES
  606.  
  607.  
  608. 3.1  COMMENTS
  609. =============
  610.  
  611.  
  612.           Comments are identified by an asterisk in column  1  and  are  copied
  613.  
  614. without modification to the output file.
  615.  
  616.  
  617.  
  618.  
  619. 3.2 LABELS
  620. ==========
  621.  
  622. Labels may be up to 8 characters long and are assumed to be upper case.
  623.  
  624.  
  625. 3.3 REGISTERS
  626. =============
  627.  
  628.  
  629.           The translator assigns the following M68000 registers as pseudo M6809
  630.  
  631. registers.   In addition, it also reserves some temporary registers for its own
  632.  
  633. use.  Any user code added after translation must preserve these registers where
  634.  
  635. necessary.
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                                      -10-
  659.  
  660.  
  661.  
  662.               M6809 to M68000 Assembly Language Source Translator
  663.               ---------------------------------------------------
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.          M6809          M68000           comments
  671.          -----          ------           --------
  672.            A             D0.B
  673.            B             D1.B
  674.            D             D2.W    <---- only created when required
  675.            X             A0.W
  676.            Y             A1.W
  677.           DP             A4.W    <---- bits 8 to 15
  678.            U             A5.W
  679.            S             A6.W
  680.  
  681.                          D3.L          scratch data register
  682.                          D4.L          address pass through register
  683.                          D5.W          SR temporary holding register
  684.                          A2.L          PC for PCR simulation when needed
  685.                          A3.L          scratch address register
  686.                          A7.L          system stack pointer
  687.  
  688.  
  689.           All  operations are byte or word sized except when sign extention may
  690.  
  691. cause a problem (for example, when loading  address  registers,  pulling  words
  692.  
  693. from  a  stack  (using MOVEM) or as a consequence of the translation of certain
  694.  
  695. addressing  modes).   It  is  therefore  necessary  to  ensure  that  the  most
  696.  
  697. significant  (essentially  unused)  bits  of  the  data registers remain clear,
  698.  
  699. otherwise invalid data may be transfered.  For example :
  700.  
  701.  
  702.  
  703.  
  704. 1)  TFR  D,X  ------>   BSR    ..DIN          create D reg
  705.                         MOVE.L D2,A0          move to X
  706.                         BSR    ..DOUT         update A & B
  707.  
  708.     The last line is redundant and would be removed by the optimiser (if
  709.     called).
  710.  
  711. 2)  LDA  [B,Y] ----->   MOVE.L (A1,D1.W),A2   get effective address
  712.                         MOVE.B (A2),D0        get data
  713.  
  714.  
  715.           In example (1), the D  reg  is  created  by  concatenating  A  and  B
  716.  
  717. registers  (refer  to stub listing file).  Note that the MOVE operation is long
  718.  
  719. word to avoid sign extension.  Any invalid data in unused parts  of  D0  or  D2
  720.  
  721. will  therefore  cause an incorrect value to be loaded into A0 (X).  In example
  722.  
  723.  
  724.                                      -11-
  725.  
  726.  
  727.  
  728.               M6809 to M68000 Assembly Language Source Translator
  729.               ---------------------------------------------------
  730.  
  731.  
  732.  
  733. (2), during the effective address calculation, the D1 (B) register  has  to  be
  734.  
  735. word  sized.   It will also be sign extended to 32 bits.  Consequently, invalid
  736.  
  737. data in bits 8 to 15 of D1 may produce an incorrect effective address.
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.                                      -12-
  791.  
  792.  
  793.  
  794.               M6809 to M68000 Assembly Language Source Translator
  795.               ---------------------------------------------------
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. 3.4 CONSTANTS
  803. =============
  804.  
  805.  
  806.           Constants  are  generally  not  modified by the translator.  The only
  807.  
  808. exception to this rule  is  the  checking  of  string  and  character  constant
  809.  
  810. delimiters.   The  only  delimiters  permitted  are  '  and  " characters.  The
  811.  
  812. translator ensures that all occurances of string and  character  constants  are
  813.  
  814. delimited  (at  both  ends) with a ' character to ensure compatibility with the
  815.  
  816. Motorola M68000 assembler.
  817.  
  818.  
  819.  
  820.  
  821. 3.5 EXPRESSIONS
  822. ===============
  823.  
  824. Expressions are not modified by the translator.
  825.  
  826.  
  827. 3.6 MACROS
  828. ==========
  829.  
  830.  
  831.           The  translator  supports  M6809  assembler  macro  calls.   As macro
  832.  
  833. definitions are encountered by the translator, their names  are  stored  in  an
  834.  
  835. table.   Should the translator be subsequently unable to match an opcode to any
  836.  
  837. database entry, it will scan the macro name table for a match before issuing an
  838.  
  839. "Unable to translate" error message.  The translator is able to store up to 100
  840.  
  841. macro identifiers.  Exceeding this limit will produce an error.
  842.  
  843.  
  844.  
  845.  
  846. 3.7 ADDRESSING MODES
  847. ====================
  848.  
  849.  
  850.           The  translator  supports  all M6809 addressing modes.  The following
  851.  
  852. paragraphs provide typical examples for  the  translation  of  each  addressing
  853.  
  854.  
  855.  
  856.                                      -13-
  857.  
  858.  
  859.  
  860.               M6809 to M68000 Assembly Language Source Translator
  861.               ---------------------------------------------------
  862.  
  863.  
  864. mode.
  865.  
  866.  
  867.  
  868. 3.7.1  Inherent
  869.  
  870.          COMA      ===============>    NOT.B   D0
  871.                                        ORI.B   $01,CCR
  872.  
  873. 3.7.2  Immediate
  874.  
  875.          ORA   $FE  =============>    OR.B    $FE,D0
  876.                                     ** WARNING       C-BIT CLEARED
  877.  
  878. 3.7.3  Extended
  879.  
  880.          INC  $2000  =============>    ADDQ.B  1,$2000
  881.                                     ** WARNING       C-BIT MODIFIED
  882.  
  883. 3.7.4  Direct
  884.  
  885.          STA  <TEMP  =============>    MOVE.B   D0,TEMP(A4)
  886.                                     ** WARNING       C-BIT CLEARED
  887.  
  888. 3.7.5  Indexed
  889.  
  890. 3.7.5.1  Constant offset from register
  891.  
  892.          CMPA  10,X  =============>    CMP.B    10(A0),D0
  893.  
  894.          LDA   Y     =============>    MOVE.B   0(A1),D0
  895.  
  896. 3.7.5.2  Accumulator offset from register
  897.  
  898.          CMPA  B,X   =============>    CMP.B    (A0,D1.W),D0
  899.  
  900. 3.7.5.3  Autoincrement/decrement from register
  901.  
  902.          LDA   ,X++  =============>    MOVE.B   (A0),D0
  903.                                        ADDQ.L   2,A0
  904.  
  905.          LDA   ,-X   =============>    MOVE.B   -(A0),D0
  906.  
  907.          JSR   ,X+   =============>    LEA.L    (A0),A3
  908.                                        ADDQ.L   2,A0      [NOTE ORDER OF
  909.                                        BSR      ..JSR       OPERATION]
  910.  
  911. 3.7.5.4  Indirection
  912.  
  913.                                  NOTE
  914.                                  ====
  915.              To minimise code overhead, the translator assumes that
  916.           indirect addresses reside within the range $0 to $7FFF.
  917.           Ofcourse, this may not be true, in which case additional code
  918.           must be selectively added after translation to avoid sign
  919.           extension of the indirect effective address.
  920.  
  921.                                      -14-
  922.  
  923.  
  924.  
  925.               M6809 to M68000 Assembly Language Source Translator
  926.               ---------------------------------------------------
  927.  
  928.  
  929.  
  930.  
  931.  
  932.          LDA   [,X]   ============>    MOVE.W   (A0),A2    0 <= X <= $7FFF
  933.                                        MOVE.B   (A2),D0
  934.  
  935.          LDA   [$6000,Y]  ========>    MOVE.W   $6000(A1),A2    Y <= $1FFF
  936.                                        MOVE.B   (A2),D0
  937.  
  938.                           ========>    CLR.L    D4           |  Y >= $2000
  939.                                        MOVE.W   $6000(A1),D4 |-- USER
  940.                                        MOVE.L   D4,A2        |   MODIFIED
  941.                                        MOVE.B   (A2),D0
  942.  
  943. 3.7.5.5  Extended Indirect
  944.  
  945.          CMPA  [$2000] ===========>    MOVE.W   $2000,A2
  946.                                        CMP.B    (A2),D0
  947.  
  948.          CMPA  [$A000] ===========>    CLR.L    D4       |
  949.                                        MOVE.W   $A000,D4 |-- USER MODIFIED
  950.                                        MOVE.L   D4,A2    |
  951.                                        CMP.B    (A2),D0
  952.  
  953.  
  954. 3.7.5.6  Program counter relative
  955.  
  956.          LDX   MESS,PCR  =========>    CLR.L     D4
  957.                                        MOVE.W    MESS(PC),D4
  958.                                        MOVE.L    D4,A0
  959.                                     ** WARNING   C-BIT CLEARED
  960. 3.7.6  Branch relative
  961.  
  962.          LBNE  LOOPY  ============>    BNE       LOOPY
  963.  
  964.  
  965. 3.8  OPCODES
  966. ============
  967.  
  968.  
  969.           The opcode translations may be obtained through an examination of the
  970.  
  971. database files CODES and CODES2.
  972.  
  973.  
  974.  
  975.  
  976. 3.9  CONDITION CODES
  977. ====================
  978.  
  979.  
  980.           Fortunately, most M68000 instructions modify the condition codes in a
  981.  
  982. manner compatible with the M6809.  However, 100%  compatibility is not possible
  983.  
  984. without  an  unacceptable  corrective  code  overhead.  Consequently, for those
  985.  
  986.  
  987.                                      -15-
  988.  
  989.  
  990.  
  991.               M6809 to M68000 Assembly Language Source Translator
  992.               ---------------------------------------------------
  993.  
  994.  
  995.  
  996. instructions where a difference occurs, a warning will  be  issued.   The  user
  997.  
  998. should examine all warnings and modify the translator output code if necessary.
  999.  
  1000. Note that the M6809 H-bit is not supported.
  1001.  
  1002.  
  1003.           Code  is  added  to  correct  the  following  common  condition  code
  1004.  
  1005. incompatibilities.
  1006.  
  1007.  
  1008.  
  1009.  
  1010. 1)  A call to stub subroutine "..CTOX" should be inserted before M68000
  1011.     instructions that use the X-bit to copy the C-bit into the X-bit. The
  1012.     translator database includes these calls.
  1013.  
  1014. 2)  A call to stub subroutines "..CREP" and "..VREP" may be inserted after
  1015.     an instruction which corrupts the C or V flags. These routines require
  1016.     the original status register contents to be placed into register D5
  1017.     prior to execution of the instruction that corrupts the flags. The
  1018.     translator database does not include references to these calls but may
  1019.     be modified to do so if required (see Chapter 5).
  1020.  
  1021.  
  1022.           All  operands  of instructions operating with an index register (i.e.
  1023.  
  1024. M68000 address register) are passed through data register D3 in order to modify
  1025.  
  1026. the  condition  codes.  This additional instruction may be removed at the users
  1027.  
  1028. discretion after translation.
  1029.  
  1030.  
  1031.  
  1032.  
  1033. 3.10  DIRECTIVES
  1034. ================
  1035.  
  1036.  
  1037.           The  translator  will  accept  and translate most commonly used M6809
  1038.  
  1039. assembler directives.  The CODES2 database file should be examined for  a  list
  1040.  
  1041. of   those  supported.   Additional  directives  (or  those  from  non-Motorola
  1042.  
  1043. compatible M6809 assemblers) may be added  (see  Chapter  5).   The  translator
  1044.  
  1045. handles the "NAM" and "END" directives in the following manner.
  1046.  
  1047.  
  1048.  
  1049.  
  1050.          NAM    <name>    =====>  <name>    IDNT  1,1
  1051.  
  1052.  
  1053.                                      -16-
  1054.  
  1055.  
  1056.  
  1057.               M6809 to M68000 Assembly Language Source Translator
  1058.               ---------------------------------------------------
  1059.  
  1060.  
  1061.  
  1062.          END              =====>            END
  1063.  
  1064.          END    <label>   =====>  ..START   EQU    <label>
  1065.                                             XDEF  ..START
  1066.                                             END
  1067.  
  1068.  
  1069.           The  label  ..START  is  an external reference for the initialisation
  1070.  
  1071. stub which must be linked with the final translated code  after  assembly.   It
  1072.  
  1073. defines  the  address  to  which  the initialisation stub must jump in order to
  1074.  
  1075. commence execution of the users code.  The program should  start  execution  at
  1076.  
  1077. the label ..INIT.
  1078.  
  1079.  
  1080.  
  1081.  
  1082. 3.11 HINTS
  1083. ==========
  1084.  
  1085.  
  1086.           The following hints will improve the translation efficiency  and  may
  1087.  
  1088. help avoid translation bugs/anomolies.
  1089.  
  1090.  
  1091.  
  1092.  
  1093. 1) Avoid using the RTS instruction; use PULS PC instead.
  1094. 2) Minimise direct access of the DP register.
  1095. 3) Minimise use of instructions which use the D register and/or ...
  1096. 4) Group all D register instructions together and remove redundant D register
  1097.    manipulation stub calls.
  1098. 5) Minimise the use of the accumulator indexed addressing mode using the D
  1099.    register.
  1100. 6) Attempt to ensure, wherever practical, that indirect addressing mode
  1101.    operands lie within the address range $0 to $7FFF. The user must append
  1102.    additional code if this is not the case.
  1103. 7) All instructions which modify program flow will translate to instructions
  1104.    with long word operands.
  1105. 8) Calls to stub subroutines are relative with 16-bit offsets.
  1106. 9) The addressing mode for single character operands of characters X,Y,U or S
  1107.    is assumed to be indexed (e.g. LDA X =====> LDA 0,X)
  1108. 10) Byte field labels cannot be externally defined (XDEF).
  1109. 11) The translator will swop the register order in the operand of the EXG
  1110.     instruction if the 2nd register specified is D (M68000 EXG Ay,Dy is
  1111.     not allowed).
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                      -17-
  1120.  
  1121.  
  1122.  
  1123.               M6809 to M68000 Assembly Language Source Translator
  1124.               ---------------------------------------------------
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.                              CHAPTER  4
  1131.  
  1132.                             RESTRICTIONS
  1133.  
  1134.  
  1135. 4.1  GENERAL
  1136. ============
  1137.  
  1138.  
  1139.           The following general points should  be  observed  before  using  the
  1140.  
  1141. translator.
  1142.  
  1143.  
  1144.  
  1145.  
  1146. a) The M6809 to be translated must assemble error free.
  1147. b) Change of flow instructions must not have absolute operands (labels only).
  1148. c) Constant strings can only use " or ' delimiters.
  1149. d) Constant string delimiter combinations of '" and "' are not allowed.
  1150.    Replace with "'" or '"' .
  1151. e) The M6809 H-bit is not supported.
  1152. f) The M6809 instruction DAA is not supported. The user should modify his
  1153.    code to utilise the M68000 BCD arithmetic instructions.
  1154. g) Some code translations will not modify all condition codes correctly.
  1155. h) Unlike an assembler, the translator does not operate with a pseudo PC.
  1156.    Consequently, the direct addressing mode must always be forced by preceding
  1157.    the operand with a < character. The "force extended" character > and all
  1158.    other occurances of the < character (with other addressing modes) are
  1159.    ignored.
  1160. i) PSH and PUL instruction operands must contain the appropriate register
  1161.    list - label references are not allowed.
  1162.  
  1163.  
  1164. 4.2  STACK FRAME
  1165. ================
  1166.  
  1167.  
  1168.           In order to minimise any software overhead, little attempt  has  been
  1169.  
  1170. made  to  effect a compatible stack frame structure.  Consequently, the user is
  1171.  
  1172. responsible for reorganising any parameter passing or  other  operations  which
  1173.  
  1174. use the M6809 U or S stacks.
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                      -18-
  1186.  
  1187.  
  1188.  
  1189.               M6809 to M68000 Assembly Language Source Translator
  1190.               ---------------------------------------------------
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.                                          MSB     LSB
  1199.                                        ======= ========
  1200.                                        |  -   |   -   |
  1201.                   PUSH    PULL         |  -   |  ACCB |
  1202.          =======                       |  -   |   -   |
  1203.          | CCR |   ^        |          |  -   |  ACCA |
  1204.          | ACCA|   |        |          |  -   |   -   |
  1205.          | ACCB|   |        |          | IXH  |  IXL  |    - = NOT USED
  1206.          | DPR |   |        |          |  -   |  -    |    x = STACK POINTER
  1207.          | IXH |   |        |          | IYH  |  IYL  |
  1208.          | IXL |   |        |          |  -   |  -    |
  1209.          | IYH |   |        |          | DPR  |  -    |
  1210.          | IYL |   !        |          |  -   |  -    |
  1211.          | xSH |   !        |          | xSH  |  xSL  |
  1212.          | xSL |   !        v          |  -   |  CCR  |
  1213.          | PCH |                       | PCH  |  PCMU |
  1214.          | PCL |                       | PCML |  PCL  |
  1215.  
  1216.  
  1217.    M6809 STACKING ORDER           M68000 (PSUEDO) STACKING ORDER
  1218.    ╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧           ╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧╧
  1219.  
  1220.  
  1221.           To avoid possible problems with sign extension, all stack  operations
  1222.  
  1223. are  long  words, with the exception of the CCR (LSB of SR) which is moved as a
  1224.  
  1225. word.  The D register may be specified as  either  A,B  or  D  in  the  PSH/PUL
  1226.  
  1227. register  list,  but will always be considered as separate A and B registers by
  1228.  
  1229. the translator.
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236. 4.3 TFR/EXG INSTRUCTIONS
  1237. ========================
  1238.  
  1239.  
  1240.           EXG or TFR of the PC with a register is not supported.   EXG  of  the
  1241.  
  1242. CCR  with  another (8 bit) register, is also not supported.  These instructions
  1243.  
  1244. should be replaced with alternative M6809/M68000 code prior to translation,  as
  1245.  
  1246. shown below.  Failure to do so will produce an error.
  1247.  
  1248.  
  1249.  
  1250.  
  1251.                                      -19-
  1252.  
  1253.  
  1254.  
  1255.               M6809 to M68000 Assembly Language Source Translator
  1256.               ---------------------------------------------------
  1257.  
  1258.  
  1259.  
  1260.                           Replace with
  1261.          TFR    X,PC      ============>     JMP    ,X
  1262.  
  1263.          TFR    PC,Y      ============>     LEAY   0,PCR
  1264.  
  1265.          EXG    PC,X      ============>     MOVEA.L A0,A3    |
  1266.                                             LEA.L  2(PC),A0  |- disable
  1267.                                             JMP    (A3)      |  translator
  1268.  
  1269.  
  1270.           TFR  of  the  DP  register  to/from an (8-bit) register is permitted,
  1271.  
  1272. however, the CCR is modified (as per the M68000 MOVE instruction).
  1273.  
  1274.  
  1275.  
  1276. 4.4  (MEMORY) INDIRECT ADDRESSING
  1277. =================================
  1278.  
  1279.  
  1280.           The  M68000  will automatically sign extend word size data moved into
  1281.  
  1282. an address  register  to  32  bits.   Consider  the  indirect  addressing  mode
  1283.  
  1284. translation example shown below.
  1285.  
  1286.  
  1287.  
  1288.          STA       [0,Y]     =============>      MOVE.W   (A1),A2
  1289.                                                  MOVE.B   D0,(A2)
  1290.  
  1291.  
  1292.           To avoid the  sign  extension  problem,  it  is  necessary  that  the
  1293.  
  1294. contents  of  the word that A1 points to lie between $0 and $7FFF.  Should this
  1295.  
  1296. not be the case then the code must be modified in the  following  manner  after
  1297.  
  1298. translation.
  1299.  
  1300.  
  1301.  
  1302.  
  1303.          STA       [0,Y]    ------------->    |  CLR.L    D4   (optional)
  1304.                                               |  MOVE.W   (A1),D4
  1305.                                               |  MOVE.L   D4,A2
  1306.                                                  MOVE.B   D0,(A2)
  1307.  
  1308.  
  1309.           Note  that  the  move  through  the  data  register  will  effect the
  1310.  
  1311. condition code register.
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                      -20-
  1318.  
  1319.  
  1320.  
  1321.               M6809 to M68000 Assembly Language Source Translator
  1322.               ---------------------------------------------------
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.                              CHAPTER  5
  1331.  
  1332.                      MODIFYING THE DATABASE FILES
  1333.  
  1334.  
  1335. 5.1  GENERAL
  1336. ============
  1337.  
  1338.  
  1339.           The database files used by the translator may be modified by the user
  1340.  
  1341. to  support  additional   directives   or   provide   alternative   instruction
  1342.  
  1343. translations.  The databases contain information relating to the translation of
  1344.  
  1345. the instructions and directives.  They provide a fundamental translation  which
  1346.  
  1347. the  translator  can  generally apply to all addressing modes.  Each ASCII file
  1348.  
  1349. contains two entries (lines) for each instruction/directive.  The  first  is  a
  1350.  
  1351. tag  (instruction  identifier),  the  second  an  associated  data  string (the
  1352.  
  1353. translation).  The tags must reside on even numbered lines.
  1354.  
  1355.  
  1356.  
  1357.  
  1358. 5.2  TAG ENTRY
  1359. ==============
  1360.  
  1361.  
  1362.           The  tag entry contains the root form of the instruction (e.g.  LD is
  1363.  
  1364. the root form of LDA, LDB, LDS etc,.).  If the instruction refers to a register
  1365.  
  1366. within  its opcode, then an asterix (*) is placed in column 1 of the tag field
  1367.  
  1368. (e.g.  *LD ).
  1369.  
  1370.  
  1371.  
  1372.  
  1373. 5.3  DATA STRING
  1374. ================
  1375.  
  1376.  
  1377.           The   data  string  contains  (1)  the  instruction(s)  necessary  to
  1378.  
  1379. effectively translate the input instruction or (2)  a  corresponding  assembler
  1380.  
  1381.  
  1382.  
  1383.                                      -21-
  1384.  
  1385.  
  1386.  
  1387.               M6809 to M68000 Assembly Language Source Translator
  1388.               ---------------------------------------------------
  1389.  
  1390.  
  1391. directive.   Up to 6 instructions may be included within each data string.  The
  1392.  
  1393. following special characters are used as control  characters  or  as  codes  to
  1394.  
  1395. identify missing parameter positions.
  1396.  
  1397.  
  1398.  
  1399.  
  1400.      o   Indicates the expected position of the (translated) operand.
  1401.      p   Indicates that the translation cannot support the PC relative
  1402.          addressing mode (so the translator must take special action).
  1403.      \   Indicates the expected position of the implied register.
  1404.      ;   Indicates end of translation line - more may follow.
  1405.      ^   Separates alternative translations for registers A,B,D and U,S,X,Y.
  1406.      *   Indicates that the next "instruction" (i.e. upto the next ; character)
  1407.          is a warning.
  1408.      .   If the next character is a space then this indicates that the
  1409.          operation size attribute should be inserted by the translator.
  1410.  
  1411.  
  1412.  
  1413. 5.4  RULES
  1414. ==========
  1415.  
  1416.  
  1417. 1) Each translation data string must reside on one line of less than 100
  1418.    characters.
  1419. 2) No more than 6 translation lines are allowed per M6809 instruction
  1420.    (this includes additional lines added by the translator).
  1421. 3) Should a line contain the ^ character, then the string preceding the
  1422.    ^ will be used if the implied register is A,B or D. The string after
  1423.    the ^ will be used for implied registers U,S,X or Y.
  1424. 4) It is not generally necessary to terminate each data string entry with an
  1425.    end of line character. However, if a control character is required as the
  1426.    last character in a line, then it must be followed by a space and an
  1427.    an end of line character (;).
  1428. 5) If the operation size (byte, word or long word) is not included in the
  1429.    data string, then the translator will append it according to the
  1430.    size of the implied register.
  1431. 6) When required, the 'p' character may appear at any point within the data
  1432.    string.
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                      -22-
  1450.  
  1451.  
  1452.  
  1453.               M6809 to M68000 Assembly Language Source Translator
  1454.               ---------------------------------------------------
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460. 5.5 EXAMPLES
  1461. ============
  1462.  
  1463.  
  1464. 1) Load register from memory instruction
  1465.  
  1466.  
  1467.  register flag       translation option
  1468.    |                     delimiter                          warning
  1469.    |    operand             |                                  |
  1470.    *LD    |                 |                                  |
  1471.    MOVE.  o,D\;* C-BIT CLR *^CLR.L D4;MOVE. o,D4;MOVEA.L D4,A\;* C-BIT CLR *
  1472.         |    |                       |
  1473.         |    |                       |
  1474.   missing   register number     instruction
  1475.    size                          delimiter
  1476.  
  1477.  
  1478. 2) Complement memory instruction
  1479.  
  1480.       PC relative
  1481.          flag
  1482.           |
  1483.    COM    |
  1484.    NOT.B op;ORI.B $01,CCR
  1485.  
  1486.  
  1487. 3) Load effective address
  1488.  
  1489.          space + delimiter
  1490.               |
  1491.    *LEA      ||
  1492.    LEA.L o,A\ ;
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                      -23-
  1516.  
  1517.  
  1518.  
  1519.               M6809 to M68000 Assembly Language Source Translator
  1520.               ---------------------------------------------------
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.                              APPENDIX  A
  1528.  
  1529.                             ERROR MESSAGES
  1530.  
  1531.  
  1532. 1 -  Invalid Implied Register :
  1533.  
  1534.      The translator does not recognise implied register
  1535.  
  1536.      e.g.   LDZ  TEMP        {Z is not a valid register}
  1537.  
  1538. 2 -  Unable to translate :
  1539.  
  1540.      The translator is unable to find a match for the opcode in either
  1541.      database tag fields, or match it to a macro table entry.
  1542.  
  1543. 3 -  Too many macro names :
  1544.  
  1545.      The translator has encountered more than 100 macro definitions in the
  1546.      M6809 input source file.
  1547.  
  1548. 4 -  Invalid PSH/PUL register :
  1549.  
  1550.      The translator has encountered an invalid register name within the
  1551.      register list.
  1552.  
  1553.      e.g.   PSHU  REGLIST    {register lists cannot be equated to labels}
  1554.  
  1555. 5 -  PC not supported :
  1556.  
  1557.      The translator does not permit the PC register to be a valid register
  1558.      in the TFR and EXG M6809 instructions. Alternative M6809 code should
  1559.      be substituted.
  1560.  
  1561.      e.g.   TFR  X,PC        {PC not allowed - substitute with JMP 0,X }
  1562.  
  1563. 6 -  CCR not supported :
  1564.  
  1565.      The translator does not permit the CCR register to be a valid register
  1566.      in the EXG instruction. Alternative M6809/M68000 code should be
  1567.      substituted.
  1568.  
  1569.      e.g.   EXG  A,CCR       {CCR not allowed}
  1570.  
  1571. 7 -  Invalid second (index) register :
  1572.  
  1573.      The translator is umable to identify the index register within the
  1574.      operand.
  1575.  
  1576.      e.g.   LDA  TEMP,Z      {Z is not a valod register}
  1577.  
  1578.  
  1579.  
  1580.  
  1581.                                      -24-
  1582.  
  1583.  
  1584.  
  1585.               M6809 to M68000 Assembly Language Source Translator
  1586.               ---------------------------------------------------
  1587.  
  1588.  
  1589.  
  1590. 8 -  Invalid first register :
  1591.  
  1592.      The translator is unable to identify the first register encountered
  1593.      in the operand of an EXG or TFR instruction.
  1594.  
  1595.      e.g.   TFR  Z,A         {z is not a valid register}
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                      -25-
  1648.  
  1649.  
  1650.